package com.ito.ito.areaTrabajo.modelo;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

@Entity
@Table(name = "estructura")
public class Estructura implements Serializable {
	private static final long serialVersionUID = 1L;
	//
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	@Column(name = "idEstructura", nullable = false)
	private Long idEstructura;
	// relacion
	@ManyToOne(optional = true)
	@JoinTable(name = "plantilla_estructura", joinColumns = { @JoinColumn(name = "idEstructura") }, inverseJoinColumns = { @JoinColumn(name = "idPlantilla") })
	private Plantilla plantilla;

	@OneToMany(cascade=CascadeType.ALL)
	@JoinTable(name="estructura_contenedores",joinColumns={@JoinColumn(name="idEstructura")},inverseJoinColumns={@JoinColumn(name="idContenedor")})
	private List<Contenedor> contenedores=new ArrayList<Contenedor>();

	// gets an sets
	public Long getIdEstructura() {
		return idEstructura;
	}

	public void setIdEstructura(Long idEstructura) {
		this.idEstructura = idEstructura;
	}

	public Plantilla getPlantilla() {
		return plantilla;
	}

	public void setPlantilla(Plantilla plantilla) {
		this.plantilla = plantilla;
	}

	public List<Contenedor> getContenedores() {
		return contenedores;
	}

	public void setContenedores(List<Contenedor> contenedores) {
		this.contenedores = contenedores;
	}

}
